﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using QLST_DTO;

namespace QLST_DAO
{
    public class KHACHHANGDAO : TempDAO
    {
        //public int Insert(KHACH_HANG kh)
        //{
        //    DataTable tbl = dap.ExcuteProcedureGetTable("st_GetSanPhamTheoMa", parameters);
        //}
        /// <summary>
        /// Lay thong tin khach hang DAO
        /// </summary>
        /// <returns></returns>
        public DataTable Get()
        {
            DataTable tbl = dap.ExcuteProcedureGetTable("st_GetKhachHang", null);
            return tbl;

        } 
        /// <summary>
        /// Lay khach hang theo ma
        /// </summary>
        /// <param name="MaKH"></param>
        /// <returns></returns>
        public KHACH_HANG Get(int MaKH)
        {
            SqlParameter[] parameters = new SqlParameter[1];
            parameters[0] = new SqlParameter("@MaKH", MaKH);
            DataTable tbl = dap.ExcuteProcedureGetTable("st_GetKHTheoma", parameters);
            if (tbl.Rows.Count > 0)
            {
                DataRow dr = tbl.Rows[0];
                KHACH_HANG kh = new KHACH_HANG();
                kh.CMND = int.Parse(dr["CMND"].ToString());
                kh.DiaChi = dr["DiaChi"].ToString();
                kh.DienThoai = dr["DienThoai"].ToString();
                return kh;
              
            }
            return null;

        }
    }
}

